package cn.iocoder.yudao.module.crossborder.platform.framework.security.config;

import cn.iocoder.yudao.framework.security.config.AuthorizeRequestsCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configurers.AuthorizeHttpRequestsConfigurer;
import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer;

/**
 * CrossBorder 模块的 Security 配置
 */
@Configuration(proxyBeanMethods = false, value = "crossBorderSecurityConfiguration")
public class SecurityConfiguration {

    @Bean("crossBorderAuthorizeRequestsCustomizer")
    public AuthorizeRequestsCustomizer authorizeRequestsCustomizer() {
        return new AuthorizeRequestsCustomizer() {

            @Override
            public void customize(AuthorizeHttpRequestsConfigurer<HttpSecurity>.AuthorizationManagerRequestMatcherRegistry registry) {
                // Webhook 回调接口，无需登录验证
                registry.antMatchers("/admin-api/crossborder/webhook/**").permitAll();
                // 平台健康检查接口，无需登录验证
                registry.antMatchers("/admin-api/crossborder/platform/health").permitAll();
            }


        };
    }

}
